home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1997
/
MacHack 1997.toast
/
Hacks
/
Hacks ’97
/
Whack-A-Bill
/
source code
/
async.h
< prev
next >
Wrap
Text File
|
1997-09-24
|
1KB
|
99 lines
void PlayAsync(int drawState);
void SetupSound(void);
void DisposeSound(void);
SndChannelPtr channelArray[10];
Handle soundOne;
Handle soundTwo;
int lastSoundPlayed;
void PlayAsync(int drawState)
{
int foundChan=0;
Boolean chanSet=false;
int openChan = 0;
SCStatus chanStatus;
OSErr err;
Handle theSound;
if (!(drawState==lastSoundPlayed))
{
switch (drawState)
{
case 1:
theSound=soundOne;
lastSoundPlayed = 1;
break;
case 2:
theSound=soundTwo;
lastSoundPlayed = 2;
break;
case 3:
theSound=soundOne;
lastSoundPlayed = 3;
break;
case 4:
lastSoundPlayed = 4;
break;
case 5:
lastSoundPlayed = 5;
theSound=soundTwo;
break;
case 6:
lastSoundPlayed = 6;
theSound=soundTwo;
break;
case 7:
lastSoundPlayed = 7;
theSound=soundTwo;
break;
case 8:
lastSoundPlayed = 8;
theSound=soundTwo;
break;
}
while (chanSet==false)
{
SndChannelStatus(channelArray[openChan],sizeof(chanStatus),&chanStatus);
if(!(chanStatus.scChannelBusy))
{
chanSet=true;
}
else openChan++;
if (openChan>9)
chanSet=true;
}
if(!(openChan>9))
{
SndPlay(channelArray[openChan],(SndListHandle)theSound,true);
}
}
}
void SetupSound(void)
{
int i;
for (i=0;i<10;i++)
{
channelArray[i] = nil;
SndNewChannel(&channelArray[i],sampledSynth,0,nil);
}
soundOne=GetResource('snd ',400);
soundTwo=GetResource('snd ',401);
}
void DisposeSound(void)
{
int i;
for (i=0;i<10;i++)
{
SndDisposeChannel(channelArray[i],true);
}
}